As you may have mentioned, lot of iPhone apps (especially games) run by default in landscape mode! You can easily force the app you develop to run in landscape mode! Let’s see how:
- In Xcode find the file [YourAppName]-Info.plist and open it up.
- Right click on the table and select “Add Row”. Select “Initial interface orientation” and set the value to Landscape (left or right).
- Right click again and add Status bar is initially hidden.This is optional, it has nothing to do with view orientation, but it will hide the status bar.
- Open [YourAppName]ViewController.m file and uncomment the following:
// Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait);
- Change the code you just uncommented to look like this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); }
Parameter
interfaceOrientation == UIInterfaceOrientationLandscapeRight
starts the app with the Home button at the right side. interfaceOrientation == UIInterfaceOrientationLandscapeLeft
starts the app with the Home button at the left side. Set the same landscape orientation that you’ve set in Info.plist file.
Thanks a lot, I needed this and it is very simply explained.